package com.zgxt.demo.service.impl;



import com.zgxt.demo.entity.Admin;
import com.zgxt.demo.mapper.AdminMapper;
import com.zgxt.demo.service.AdminService;
import com.zgxt.demo.util.Conversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl implements AdminService {

    //时间类
    Conversion conversion=new Conversion();

    @Autowired
    AdminMapper adminMapper;


    @Override
    public Admin adminLogin(String account, String password) {
        return adminMapper.adminLogin(account,password);
    }

    @Override
    public Integer updateAdmin(Integer id, String name) {
        return adminMapper.updateAdmin(id,name,conversion.Time());
    }

    @Override
    public Integer updatePassword(Integer id, String password) {
        if(adminMapper.selectPassword(id).equals(password)){
            return 2;
        }
        return adminMapper.updatePassword(id,password,conversion.Time());
    }
}
